//
//  WQStatus.swift
//  sanwuWeibo
//
//  Created by 王先强 on 15/12/10.
//  Copyright © 2015年 王先强. All rights reserved.
//

import UIKit

class WQStatus: NSObject {

    
    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博创建时间
    var created_at: String?
    /// 微博来源
    var source: String?
    /// 缩略图配图数组 key: thumbnail_pic
    var pic_urls: [[String: String]]?
    /// 被转发的原微博信息字段
    var retweeted_status: WQStatus?
    /// 用户模型
    var user: WQUser?
    
    init(dict: [String: AnyObject]){
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        //    setValuesForKeysWithDictionary(dict) 调用这个方法
        //    拦截重新设置用户模型
        if key == "user" {
            //拿到字典进行字典转模型
            user = WQUser(dict: value as! [String: AnyObject])
            
            return
        }
        //    拦截重新设置转发微博
        if key == "retweeted_status" {
            retweeted_status = WQStatus(dict: value as! [String: AnyObject])
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
//    override var description: String {
//        return descriptionFromClazz(WQStatus)
//    }
    
}
